function loadCommentList(param, data, slot)
{		
	Packages.system.display.Progress.createInstance(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentListContainer"));

	//
	if (data.pageNum==null)
	{
		commentPageNum=1;
	}
	else commentPageNum=data.pageNum;

	startIndex=(commentPageNum-1)*10;
	
	Packages.modula.RequestCommand.request("HTTP", "restlet/books/"+bookId+"/bookcomments?startIndex="+startIndex+"&count=10", null, Packages.model.vo.CommentListView, displayMode.commentList, this, {container:"commentListContainer", dynamicPortlet:dynamicPortletArr.commentList});

	dynamicPortletArr.commentList="commentListInfo";
}

function loadCommentCreation()
{
	
	var commentListContainer=Packages.system.mlf.GateKeeper.scanElement(this._name, "commentListContainer");
	Packages.system.display.Progress.createInstance(commentListContainer);

	Packages.system.mlf.GateKeeper.updateDynamicPortlet(commentListContainer.commentListInfo, "app/vo/CommentCreate.xml");

	dynamicPortletArr.commentList="commentCreate";
}

function confirmBookComment()
{
	var body=Packages.system.mlf.GateKeeper.scanElement(this._name, "commentBody");
	//Packages.log("comment body:"+body+" value:"+body.htmlText);

	var obj:Object=new Object();
	obj.memberId=Packages.model.UserProfile.data.memberId+"";
	obj.bookId=Packages.model.Context.address.id+"";
	obj.comment=body.text;
	//Packages.log(this+".bookCommentCreate...bookId="+obj.bookId+" memberId="+obj.memberId); 
	var data:Object=new Object();
	// data.path=target._parent;
	data.name="BookSpecial";
	data.uri="app/content/bookPage/BookSpecial.xml";
	data.returnPath="loadCommentList";
	data.container="commentListContainer";
	data.oper="bookCommentCreate";
	data.dynamicPortlet=dynamicPortletArr.commentList;

	dynamicPortletArr.commentList="commonRemotingResult";

	Packages.modula.RequestCommand.request("REMOTING", "bookCommentCreate", obj, Packages.model.vo.CommonRemotingResultView, displayMode.commentList, this, data);
}

function expandCommentMore()
{
	var cellPortlet=Packages.system.mlf.GateKeeper.scanElement(this._name, "commentList");
		
	Packages.system.display.JAccordion.invokeReleaseEvent(mlf.mcmanager.PathResolver.drawPath(cellPortlet.header));
}

function previousCommentList()
{
	if (commentPageNum>1)
	{
		commentPageNum--;
		loadCommentList(null, {pageNum:commentPageNum});
	}
}

function nextCommentList()
{
	// TODO: record total
	var pageMax=10;
	if (commentPageNum<pageMax)
	{
		commentPageNum++;
		loadCommentList(null, {pageNum:commentPageNum});
	}
}

function onCommentListInit()
{
	Packages.system.render.Transition.irisType1(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentListContainer"));
	
	var evtTargetArr:Array=new Array();
	evtTargetArr.push(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentPostSpot"));
	evtTargetArr.push(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentMoreSpot"));

	if (displayMode.commentList=="expand")
	{
		evtTargetArr.push(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentListPreSpot"));
		evtTargetArr.push(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentListNextSpot"));

		var commentListCurrentPage=Packages.system.mlf.GateKeeper.scanElement(this._name, "commentListCurrentPage");
		commentListCurrentPage.text=commentPageNum;
		var tf_fmt:TextFormat=new TextFormat();
		tf_fmt.align="right";
		commentListCurrentPage.setTextFormat(tf_fmt);
	}

	Packages.system.events.StateFulButtonEvent.initialize(evtTargetArr);
}

function onCommentCreateInit()
{
	var commentListContainer=Packages.system.mlf.GateKeeper.scanElement(this._name, "commentListContainer");
	Packages.system.display.Progress.removeInstance(commentListContainer);

	Packages.system.render.Transition.irisType1(commentListContainer);
	
	var evtTargetArr:Array=new Array();
	evtTargetArr.push(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentConfirmSpot"));
	evtTargetArr.push(Packages.system.mlf.GateKeeper.scanElement(this._name, "commentReturnSpot"));
	Packages.system.events.StateFulButtonEvent.initialize(evtTargetArr);
}